package com.example.spring_xx_u_market;

import com.example.bean.ErrorCodeV;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

import static com.example.spring_xx_u_market.SpringXxUMarketApplication.jdbcTemplate;

@Slf4j
@RestController
@RequestMapping("api")
public class LogOutCtrl {
    @PostMapping("logout")
    public Object getLogin(HttpServletRequest request) {
        String uid = request.getParameter("uid");
        if (uid == null) {
            return new ErrorCodeV("005");
        } else {
            jdbcTemplate.update("delete from second_hand.uid where uid=?", uid);
            return new ErrorCodeV("0");
        }
    }
}
